'use strict';

module.exports = app => {
    const { Sequelize, model } = app

    const Model = model.define('minaCity', {
        id:{
            type: Sequelize.STRING.BINARY,
            defaultValue: Sequelize.UUIDV1,
            primaryKey: true
        },
        name: {
            type: Sequelize.STRING(20),
            allowNull: false,
            comment: '城市名'
        },
        provinceAb: {
            type: Sequelize.STRING(4),
            allowNull: false,
            comment: '城市简称'
        },
        postalCode: {
            type: Sequelize.STRING(20),
            unique: true,
            allowNull: false,
            comment: '邮政编码'
        },
        phoneCode: {
            type: Sequelize.STRING(10),
            unique: true,
            allowNull: false,
            comment: '长途区号'
        },
        longitude: {
            type: Sequelize.DOUBLE,
            allowNull: false,
            comment: '市中心经度'
        },
        latitude: {
            type: Sequelize.DOUBLE,
            allowNull: false,
            comment: '市中心纬度'
        },
        inspectionFee: {
            type: Sequelize.INTEGER(6),
            allowNull: false,
            comment: '年检费'
        },
        entrustmentFee: {
            type: Sequelize.INTEGER(6),
            allowNull: false,
            comment: '外地委托费'
        },
        // 开放服务JSON结构
        /**
         * {
         *  "isOpen": true,
         *  "serviceFee": 15800,
         * ["brokerage"]: 6000,
         * ["reward"]: 2000,
         * }
         */
        openService_1: {
            type: Sequelize.JSON,
            comment: '代驾年检'
        },
        openService_2: {
            type: Sequelize.JSON,
            comment: '到站代办'
        },
        openService_3: {
            type: Sequelize.JSON,
            comment: '自主约检'
        },
        flag: {
            type: Sequelize.INTEGER(2),
            allowNull: false,
            comment: '开放状态'
        },
    }, {
        freezeTableName: true,
        tableName: 'mina_city',
        timestamps: true,
        paranoid: true,
    })

    return Model
}